Change response types for POJOs that map one to many#6024
Merged
Conversation
zoewangg
requested changes
Apr 11, 2025
.../resources/software/amazon/awssdk/v2migrationtests/maven/after/src/main/java/foo/bar/S3.java
Show resolved
Hide resolved
...in/java/software/amazon/awssdk/v2migration/openrewrite/ChangeMethodInvocationReturnType.java
Outdated
Show resolved
Hide resolved
zoewangg
approved these changes
Apr 14, 2025
...in/java/software/amazon/awssdk/v2migration/openrewrite/ChangeMethodInvocationReturnType.java
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Motivation and Context
There are a handful of POJOs in v1 that map to two types in v2. For instance, v1
AccessControlListis used as input tosetObjectAcl(), and also returned as response fromgetObjectAcl().In v2,
AccessControlPolicyis used as input, whileGetObjectAclResponseis returned as the response.Modifications
Forked
ChangeMethodInvocationReturnTyperecipe from OpenRewrite. It is a newer recipe so requires OR version bump, which introduces breaking changes with existing SDK recipes.https://github.com/openrewrite/rewrite/blob/main/rewrite-java/src/main/java/org/openrewrite/java/ChangeMethodInvocationReturnType.java
Using this recipe to correctly change response types based on the method, returning the following responses:
Additional changes:
AmazonS3ExceptiontoS3ExceptionBucketLoggingConfigurationtoBucketLoggingStatusCannedAccessControlListtoObjectCannedACLBucketCannedACLorObjectCannedACLBucketNamewithBucketin getter methods (already in place for setters)getBucketLocation()to appendlocationConstraint().toString()as v1 returns the String regionTesting
Added end to end tests